#ifndef HE_SOCKETMANAGER_HPP_INCLUDED
#define HE_SOCKETMANAGER_HPP_INCLUDED

#include <stdio.h>
#include <string.h>

/////////////////////////////////////////////

class cSocketManager
{
    /// The socket manager! Yay!

    //-----------------------------------------------//
    //------------------ PUBLIC ---------------------//
    //-----------------------------------------------//

    public:

        //  Construction
        cSocketManager();

        //  Destruction
        ~cSocketManager();

        //--------------- Public Methods ------------------//

        /// StartTimer - This stores the most recent system time accurate to microseconds
        void StartTimer();

        /// FinishRTI - This checks how much time is left before the main loop must continue, and waits that long.
        void FinishRTI();

        /// SetFrequency - This allows outside callers to set how many times per second the servos will attempt to update. UP TO 50hz (hardware limit)
        void SetFrequency( int Frequency );

        /// EnableDebugOutput - Turns on several print statements to assist in debugging
        void EnableDebugOutput() { mDebuggingOutput = true; }

    //----------------------------------------------//
    //------------------ PRIVATE -------------------//
    //----------------------------------------------//

    private:

        //  Any Needed private methods go here


        //  Private member vars (ALL member vars should be private)
        int mCurrentFrequency;

        double mSecPerRTI;
        double mStartingTime;
        double mFinishingTime;
        double mWaitingTime;

        bool mDebuggingOutput;

        //  Timekeepers
        struct timeval sStartingTime;
        struct timeval sFinishingTime;
        useconds_t mWait_USec;

};

#endif // HE_SOCKETMANAGER_HPP_INCLUDED
